package tianrun.ziguan.api.calculate.config.service.influxdb.common;

import org.influxdb.querybuilder.clauses.RawTextClause;
import tianrun.ziguan.api.calculate.config.enums.QueryTypeEnum;

import java.util.Collection;

public class QueryBody {

    private Collection<String> tableName;

    private Long startTime;
    private Long endTime;
    private QueryTypeEnum scope;
    public RawTextClause labelsCondition;
    public RawTextClause groupingBy;

    public static QueryBody of(InquirerBody body) {
        QueryBody queryBody = new QueryBody();
        queryBody.setStartTime(body.getStartTime());
        queryBody.setEndTime(body.getEndTime());
        queryBody.setScope(body.getScope());
        queryBody.setLabelsCondition(body.labelsCondition());
        queryBody.setGroupingBy(body.groupingBy());
        queryBody.setTableName(body.getTableName());
        return queryBody;
    }

    public Collection<String> getTableName() {
        return tableName;
    }

    public void setTableName(Collection<String> tableName) {
        this.tableName = tableName;
    }

    public Long getStartTime() {
        return startTime;
    }

    public void setStartTime(Long startTime) {
        this.startTime = startTime;
    }

    public Long getEndTime() {
        return endTime;
    }

    public void setEndTime(Long endTime) {
        this.endTime = endTime;
    }

    public QueryTypeEnum getScope() {
        return scope;
    }

    public void setScope(QueryTypeEnum scope) {
        this.scope = scope;
    }

    public RawTextClause getLabelsCondition() {
        return labelsCondition;
    }

    public void setLabelsCondition(RawTextClause labelsCondition) {
        this.labelsCondition = labelsCondition;
    }

    public RawTextClause getGroupingBy() {
        return groupingBy;
    }

    public void setGroupingBy(RawTextClause groupingBy) {
        this.groupingBy = groupingBy;
    }
}
